{include file='_header'}
<div class="page-header">
	当前位置：<span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}店员 <small>{if !empty($item['id'])}修改【{$item['salername']}】{/if}</small></span>
</div>
<div class="page-content">
    <div class="page-sub-toolbar">
        <a class="btn btn-primary btn-sm" href="{:url('admin/merch/saleradd')}">添加新店员</a>
    </div>
    <form action="" method="post" class="form-horizontal form-validate" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$item['id']}" />
            <div class="form-group">
                <label class="col-lg control-label must">选择会员</label>
                <div class="col-sm-9 col-xs-12">
                       {:tpl_selector('mid',array('key'=>'id', 'required'=>true, 'text'=>'nickname', 'thumb'=>'avatar','placeholder'=>'昵称/姓名/手机号','buttontext'=>'选择会员 ', 'items'=>$saler,'url'=>url('admin/member/query',array('no_wa'=>1))))}
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg control-label must">店员姓名</label>
                <div class="col-sm-9 col-xs-12">
                    <input type="text" name="salername" class="form-control" value="{$item['salername']}" data-rule-required='true'/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg control-label must">手机号</label>
                <div class="col-sm-9 col-xs-12">
                    <input type="text" name="mobile" class="form-control" value="{$item['mobile']}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg control-label must">所属门店</label>
                <div class="col-sm-9 col-xs-12">
                    <select class="form-control tpl-category-parent select2" id="storeid" name="storeid">
                        <option value="0">请选择所属门店</option>
                        {foreach name='stores' item='store'}
                        <option value="{$store['id']}" {if $item['storeid'] == $store['id']}selected="true"{/if}>{$store['storename']}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg control-label must">用户名</label>
                <div class="col-sm-9 col-xs-12">
                    {if empty($item['username'])}
                        <input type="text" name="username" class="form-control" value="{$item['username']}" data-rule-required='true'/>
                    {else}
                        <div class='form-control-static'>{$item['username']}</div>
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg control-label {if empty($item)} must{/if}">登陆密码</label>
                <div class="col-sm-9 col-xs-12">
                    <input type="text" name="pwd" class="form-control" value="" />
                </div>
            </div>
            <div class="form-group" style="display: none;">
                <label class="col-lg control-label">所属角色</label>
                <div class="col-sm-9 col-xs-12">
                    <input type='hidden' id='userid' name='roleid' value="{$role['id']}" />
                    <div class='input-group'>
                        <input type="text" name="user" maxlength="30" value="{$role['rolename']}" id="user" class="form-control" readonly/>
                        <div class='input-group-btn'>
                            <button class="btn btn-default" type="button" onclick="popwin = $('#modal-module-menus1').modal();">选择角色</button>
                            <button class="btn btn-danger" type="button" onclick="$('#userid').val('');$('#user').val('');">清除选择</button>
                        </div>
                    </div>
                    <span class='help-block'>如果您选择了角色，则此用户本身就继承了此角色的所有权限</span>
                    <div id="modal-module-menus1"  class="modal fade" tabindex="-1">
                        <div class="modal-dialog" style='width: 920px;'>
                            <div class="modal-content">
                                <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close2" type="button">×</button><h3>选择角色</h3></div>
                                <div class="modal-body" >
                                    <div class="row">
                                        <div class="input-group">
                                            <input type="text" class="form-control" name="keyword" value="" id="search-kwd1" placeholder="请输入角色名称" />
                                            <span class='input-group-btn'><button type="button" class="btn btn-default" onclick="search_users();">搜索</button></span>
                                        </div>
                                    </div>
                                    <div id="module-menus1" style="padding-top:5px;"></div>
                                </div>
                                <div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg control-label">状态</label>
                <div class="col-sm-9 col-xs-12">
                    <label class='radio-inline'>
                        <input type='radio' name='status' value=1' {if $item['status']==1}checked{/if} /> 启用
                    </label>
                    <label class='radio-inline'>
                        <input type='radio' name='status' value=0' {if $item['status']==0}checked{/if} /> 禁用
                    </label>
                </div>
            </div>              
           <div class="form-group"></div>
            <div class="form-group">
                <label class="col-lg control-label"></label>
                <div class="col-sm-9 col-xs-12">
                    <input type="submit" value="提交" class="btn btn-primary"  />
                   <input type="button" name="back" onclick='history.back()' value="返回列表" class="btn btn-default" />
                </div>
            </div>
    </form>
</div>

<script language='javascript'>
    $(document).ready(function () {
        $('#openid_text').focusout(function () {
            return false;
        })
    })

    function search_users() {
        $("#module-menus1").html("正在搜索....")
        $.get('{:url("store/perm/role/query")}', {
            keyword: $.trim($('#search-kwd1').val())
        }, function(dat){
            $('#module-menus1').html(dat);
        });
    }

    function select_role(o) {
        $("#userid").val(o.id);
        $("#user").val( o.rolename );
        $(".close2").click();
    }
</script>

{include file='_footer'}

 